package com.xique.door.controller;

import cn.hutool.core.lang.Snowflake;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.door.bean.domain.fenqiao.Community;
import com.xique.door.bean.request.fenqiao.CommunityPersonInfoRequest;
import com.xique.door.service.CommunityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;


/**
 * 枫桥人口普查控制器
 * hsj
 */
@RequestMapping("/fenqiao")
@RestController
public class FqCommunityController {


    @Autowired
    private CommunityService communityService;


    /**
     * 添加社区人员信息
     *
     * @param communitys
     * @return
     */
    @PostMapping("/add")
    public AjaxResult addPersonInfo(@RequestBody List<Community> communitys) {
        return communityService.addPersonInfo(communitys);
    }



    /**
     * 查询人员信息
     *
     * @param request
     * @return
     */
    @GetMapping("/query")
    public AjaxResult selectPersonInfo(CommunityPersonInfoRequest request) {
        return communityService.selectPersonInfo(request);
    }

    /**
     * 查询具体人员信息
     */
    @GetMapping("/selectDetail")
    public AjaxResult selectDetail(Long id){
        return communityService.selectDetail(id);
    }

    /**
     * 批量删除人员
     * @param ids
     * @return
     */
    @DeleteMapping("/delete")
    public AjaxResult deletePersonInfo(Long[] ids) {
        return communityService.deletePersonInfo(ids);
    }


    /**
     * 更新人员信息
     *
     * @param communitys
     * @return
     */
    @PostMapping("/update")
    public AjaxResult updatePersonInfo(@RequestBody  List<Community> communitys) {
        return communityService.updatePersonInfo(communitys);
    }

    /**
     * 导出
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, CommunityPersonInfoRequest request) throws IOException {
        communityService.export(response,request);
    }



}
